# -*- coding: utf-8 -*-

import logging

PROGRESS = 23
EXTRACTION_FAIL = 22
EXTRACTION = 21
PAGE = 20
OPERATION = 10

logLevel = OPERATION
consoleHandler = logging.StreamHandler()
loggers = []


def init_logger(level=OPERATION, file="spider.log"):
    for logger in loggers:
        logger.setLevel(level)
        logger.addHandler(logging.FileHandler(file))


def get_logger(name=None):
    logger = logging.getLogger(name=name)
    logger.setLevel(logLevel)
    logger.addHandler(consoleHandler)
    loggers.append(logger)
    return logger
